<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>教师注册</title>
</head>
<!-- 引入 layui.css -->
<link rel="stylesheet" href="//unpkg.com/layui@2.6.8/dist/css/layui.css">
<!-- 引入 layui.js -->
<script src="//unpkg.com/layui@2.6.8/dist/layui.js"></script>
<script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script>
<script src="../../js/fun.js"></script>



<body>
<form class="layui-form layui-form-pane"  lay-filter="formDemo">

    <div class="layui-form-item">
        <label class="layui-form-label">名字</label>
        <div class="layui-input-block">
            <input type="text" name="name" required  lay-verify="required" placeholder="请输入名字" autocomplete="off" class="layui-input">
        </div>
    </div>


    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">简单介绍</label>
        <div class="layui-input-block">
            <textarea name="detail" placeholder="请输入介绍" class="layui-textarea"></textarea>
        </div>
    </div>



    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit="formDemo" lay-filter="formDemo">添加</button>
        </div>
    </div>
</form>
</body>



<script>

    layui.use(['form','layer'], function(){
        var form = layui.form
        //监听提交
        form.on('submit(formDemo)', function(data){
            // layer.msg(JSON.stringify(data.field));
            let registData = data.field

            $.post(Api+"/co/add",registData,function (res){
                if(res.code == "200"){
                    layer.open({
                        title:"提示",
                        content:"添加成功"
                    })
                }else {
                    layer.msg("失败")
                }
            })
            return false;
        });
    });



</script>
</html>